package com.example.souvenir.web.controller;

import com.example.souvenir.web.entity.Banner;
import com.example.souvenir.web.mapper.BannerMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class BannerController {

    @Autowired
    BannerMapper mapper;
    //把配置文件中的值读取出
    @Value("${dirPath}")
    private String dirPath;

    @RequestMapping("/banner/select")
    public List<Banner> select(){
        return mapper.select();
    }

    @RequestMapping("/banner/delete")
    public void delete(int id){
        String url=mapper.selectUrlById(id);
        mapper.deleteById(id);
    }

    @RequestMapping("/banner/insert")
    public void insert(String url){
        mapper.insert(url);
    }
}
